package com.cnpinxi.controller.web.resource;

import com.cnpinxi.controller.base.BaseController;
import com.cnpinxi.domain.ResourceRelation;
import com.cnpinxi.result.ResultObj;
import com.cnpinxi.service.ResourceRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * Created by Baggio on 2017/2/22.
 */
@RequestMapping("/resource")
@Controller
public class ResourceContorller extends BaseController {
@Autowired
ResourceRelationService resourceRelationService;

    @RequestMapping("/getResourceList")
    @ResponseBody
    public String getProductEntity(HttpServletRequest request) {
        ResultObj resultObj = new ResultObj();
        resultObj.setCode(ResultObj.CODE_SUCCESS);
        try {
            Map<String,String> map=super.showRequestParameters(request);
            List<ResourceRelation> resourceRelationList=   resourceRelationService.getResourceRelationList(map);
            resultObj.setMsg("操作成功！");
            resultObj.setData(resourceRelationList);
        } catch (Exception e) {
            resultObj.setCode(ResultObj.CODE_FAIL);
            resultObj.setMsg("操作失败！");
            e.printStackTrace();
        }
        return resultObj.toJson();
    }

}
